﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CustomTypes.Interfaces.Structure;
using Mono.Cecil;



namespace CSharpParser.Structure
{

    [System.Diagnostics.DebuggerDisplay("Type : {Name}")]
    [Serializable]
    public class TypeMonoStructure : MemberMonoStructure, ITypeStructure
    {

        public TypeMonoStructure(IMemberStructure parent, MemberReference instance, string key)
            : base(parent, instance, key)
        {
            Interfaces = new List<ITypeStructure>();
        }


        public IMemberStructure BaseType 
        {
            get 
            {
                
                var o = (Instance as TypeDefinition).BaseType;

                if (o != null)                
                    return new TypeMonoStructure(null, o, o.FullName);
                
                return null;

            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public bool IsAbstract 
        {
            get
            {
                return (Instance as TypeDefinition).IsAbstract;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsArray 
        {
            get
            {
                return (Instance as TypeDefinition).IsArray;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsClass
        {
            get
            {
                return (Instance as TypeDefinition).IsClass;
            }
            set { throw new NotImplementedException(); }
        }

        internal bool ContainsMember(string name)
        {

            throw new NotImplementedException();
     
        }

        public bool IsAnonymousType
        {
            get
            {
                return false;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsConstructed
        {
            get
            {
                return false;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsContravariant
        {
            get
            {
                return false;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsCovariant
        {
            get
            {
                return false;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsDelegate
        {
            get
            {
                return false;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsDynamic
        {
            get
            {
                return false;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsEnum
        {
            get
            {
                return (Instance as TypeDefinition).IsEnum;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsInterface 
        {
            get
            {
                return (Instance as TypeDefinition).IsInterface;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsInternal 
        {
            get
            {
                return ((Instance as TypeDefinition).Attributes & TypeAttributes.NestedFamANDAssem) == TypeAttributes.NestedFamANDAssem;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsNested 
        {
            get
            {
                return (Instance as TypeDefinition).IsNested;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsPointer 
        {
            get
            {
                return (Instance as TypeDefinition).IsPointer;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsPredefinedType 
        {
            get
            {
                return false;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsPrivate
        {
            get
            {
                return !(Instance as TypeDefinition).IsPublic;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsProtected
        {
            get
            {
                return !(Instance as TypeDefinition).IsPublic;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsProtectedOrInternal
        {
            get
            {
                return ((Instance as TypeDefinition).Attributes & TypeAttributes.NestedFamANDAssem) == TypeAttributes.NestedFamANDAssem;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsPublic
        {
            get
            {
                return (Instance as TypeDefinition).IsPublic;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsReferenceType
        {
            get
            {
                return (Instance as TypeDefinition).IsByReference;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsSealed
        {
            get
            {
                return (Instance as TypeDefinition).IsSealed;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsStatic
        {
            get
            {
                return false;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsStruct
        {
            get
            {
                throw new NotImplementedException();
                //return (Instance as TypeDefinition)
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsTypeParameter
        {
            get
            {
                return (Instance as TypeDefinition).IsGenericParameter;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsUnknown
        {
            get
            {
                return false;
            }
            set { throw new NotImplementedException(); }
        }

        public bool IsValueType
        {
            get
            {
                return (Instance as TypeDefinition).IsValueType;
            }
            set { throw new NotImplementedException(); }
        }

        public IMemberStructure UnderlyingType         
{
            get
            {
                throw new NotImplementedException();
                //return (Instance as TypeDefinition)
            }
            set { throw new NotImplementedException(); }
        }

        public string GetNamespace()
        {
            return (Instance as TypeDefinition).Namespace;
        }

        public string GetFullname()
        {
            return (Instance as TypeDefinition).FullName;
        }


        internal bool initialized = false;






        public bool IsAnsiClass
        {
            get
            {
                return (Instance as TypeDefinition).IsAnsiClass;
            }
            set { throw new NotImplementedException(); }
        }


        public bool IsSerializable
        {
            get
            {
                return (Instance as TypeDefinition).IsSerializable;
            }
            set { throw new NotImplementedException(); }
        }

        public IInterfaceStructure GetInterface(string interfaceName, bool ignoreCase)
        {
            throw new NotImplementedException();
        }

        internal List<ITypeStructure> Interfaces { get; set; }



        public IInterfaceStructure[] GetInterfaces()
        {
            throw new NotImplementedException();
        }

        public string AssemblyQualifiedName
        {
            get { throw new NotImplementedException(); }
        }

        public IGenericArgumentStructure[] GetGenericArguments()
        {
            throw new NotImplementedException();
        }

    }

}
